
#include "turboshape.h"

TurboShape::TurboShape()
{

}

TurboShape::~TurboShape()
{

}

void TurboShape::setPosLeftUp(const QPoint &point)
{
    left_up_pos_ = point;
}

QPoint TurboShape::getPosLeftUp()
{
    return left_up_pos_;
}

void TurboShape::setPosRightDown(const QPoint &point)
{
    right_down_pos_ = point;
}

QPoint TurboShape::getPosRightDown()
{
    return right_down_pos_;
}

void TurboShape::setMovePoint(const QPoint &point)
{
    move_point_ = point;
}

void TurboShape::setMoveStatus(const bool &status)
{
    move_status_ = status;
}

QVector<QPoint> TurboShape::getArrowShape()
{
    QVector<QPoint> arrow_points;
    float x1 = left_up_pos_.x();
    float y1 = left_up_pos_.y();
    float x2 = right_down_pos_.x();
    float y2 = right_down_pos_.y();

    double angle = atan2(y2 - y1, x2 - x1);				//计算线段的夹角
    float arrow_length_long = 20;						//箭头边的长度--长
    float arrow_angle_long = 0.6;						//箭头与线段的夹角--长
    float arrow_length_short = 12;						//箭头边的长度--短
    float arrow_angle_short = 0.3;						//箭头与线段的夹角--短

    float point_long_x1 = x2 - arrow_length_long * cos(angle - arrow_angle_long);
    float point_long_y1 = y2 - arrow_length_long * sin(angle - arrow_angle_long);
    float point_long_x2 = x2 - arrow_length_long * cos(angle + arrow_angle_long);
    float point_long_y2 = y2 - arrow_length_long * sin(angle + arrow_angle_long);
    float point_short_x1 = x2 - arrow_length_short * cos(angle - arrow_angle_short);
    float point_short_y1 = y2 - arrow_length_short * sin(angle - arrow_angle_short);
    float point_short_x2 = x2 - arrow_length_short * cos(angle + arrow_angle_short);
    float point_short_y2 = y2 - arrow_length_short * sin(angle + arrow_angle_short);

    arrow_points.append(left_up_pos_);
    arrow_points.append(QPoint(point_short_x1, point_short_y1));
    arrow_points.append(QPoint(point_long_x1, point_long_y1));
    arrow_points.append(right_down_pos_);
    arrow_points.append(QPoint(point_long_x2, point_long_y2));
    arrow_points.append(QPoint(point_short_x2, point_short_y2));
    arrow_points.append(left_up_pos_);

    return arrow_points;
}